<?php 
get_header();
$terms = get_the_terms( get_the_ID() , 'topics');
?>
<main class="wrapper">
	<div class="inner appbox">	
		<div class="boxtop">
			<h2><?php echo $terms[0]->name;?></h2>
			<div class="breadcrumb">
				<?php get_breadcrumbs();?>
			</div>
		</div>
		<?php if (have_posts()) : ?>
		<?php while (have_posts()) : the_post(); ?>
		<article class="post">			
			<h2 class="title"><?php the_title();?></h2>
			<div class="meta">
				<span class="date">日期：<time datetime="<?php the_time('Y-n-j'); ?>"><?php the_time('Y-n-j'); ?></time></span>
				<span class="author">作者：<?php the_author();?></span>
				<span class="views">阅读：<?php if(function_exists('the_views')) { the_views(); }else{setPostViews(get_the_ID()); echo getPostViews(get_the_ID());} ?></span>
			</div>
			<?php if(!empty($boke8['postStart'])){?>
			<div class="hmdiv">
				<?php echo htmlspecialchars_decode($boke8['postStart']);?>
			</div>
			<?php } ?>
			<div class="entry">
				<?php the_content();?>				
			</div>			
			<?php 
				the_tags('<section class="tags"><h3>关键词：</h3><ul><li>','</li><li>','</li></ul></section>');
				$posts = get_posts('numberposts=4&post_status=publish&exclude='.get_the_ID().'&category='. $terms[0]->term_id);
				if($posts){					
			?>
			<section class="relatedpost">
				<h3 class="posttitle">相关资讯</h3>
				<ul>
					<?php foreach($posts as $post){?>
					<li>
						<div class="pic">
							<a href="<?php the_permalink(); ?>" title="<?php the_title();?>" target="_blank" style="background-image: url(<?php get_template_part('functions/thumbnail');?>);"></a>
						</div>
						<div class="info">
							<h2><a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title();?>"><?php the_title();?></a></h2>
							<div class="excerpt">
								<?php echo wp_trim_words($post->post_content, 65, '...');?>
							</div>
							<div class="date">
								<time datetime="<?php the_time('Y-n-j'); ?>">
									<?php the_time('Y-n-j'); ?>
								</time>
							</div>				
						</div>
					</li>
					<?php }?>
				</ul>
			</section>
			<?php } wp_reset_postdata();?>
			<?php if (comments_open() ) { comments_template('',true); }?>
		</article>
		<?php endwhile; ?>		
		<?php else : ?>
		<div class="post">
			<p>对不起！该页面尚未添加内容，请先浏览其它网页！</p>
		</div>
		<?php endif;?>
	</div>
</main>
<?php get_footer();?>